<template>
	<!--  <view class="page"  :style="{background: `url(${backimg}) no-repeat`}"> -->
	<view class="page"
		:style="{ background: backimg ? `url(${backimg}) no-repeat` : 'url(../../static/images/74.png) no-repeat' }">
		<!---flex布局flex布局开始-->
		<view class="flex benben-flex-layout flex-wrap align-center">
			<view class='flex flex-direction flex-wrap align-center flex-sub login_fd0_0'>
				<image class='login_fd0_0_c0' mode="aspectFill" :src='STATIC_URL+"logo1.jpg"'></image>
			</view>
		</view>

		<!---flex布局flex布局结束-->
		<!---登录flex布局开始-->
		<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout login_flex_1">
			<view class='flex flex-wrap align-center login_fd1_0' @tap.stop="pickerDiy1678760201193=true">
				<image class='login_fd1_0_c0' mode="aspectFill" :src='STATIC_URL+"78.png"'></image>
				<input class='flex-sub login_fd1_0_c1' type="text" placeholder="请选择区号" confirm-type="done"
		style="pointer-events:none;" :maxlength="-1" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="area" disabled="true" />
			</view>
			<view class='flex flex-wrap align-center login_fd1_0'>
				<image class='login_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"56.png"'></image>
				<input class='flex-sub login_fd1_0_c1' type="number" placeholder="请输入手机号" confirm-type="done" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" maxlength="20" v-model="mobile" />
			</view>
			<view class='flex align-center login_fd1_0'>
				<image class='login_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"58.png"'></image>
				<benben-flex-password-diy v-model="password" class-name="flex align-center flex-sub flex login_fd1_1_c1"
					:placeholder="'请输入密码(6~12位字母+数字)'" :maxlength="12" :default-type='true'
					placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx">
					<template #show>
						<text class='fu-iconfont2  login_fd1_1_c1_icon1' data-type="show">&#xE837;</text>
					</template>
					<template #hide>
						<text class='fu-iconfont2  login_fd1_1_c1_icon2' data-type="hide">&#xEBCC;</text>
					</template>
				</benben-flex-password-diy>
			</view>
			<text class='self-end login_fd1_2' @tap.stop="handleJumpDiy" data-type="navigateTo"
				:data-url="`/pages/dlzc/codeLogon/codeLogon`">验证码登录</text>
			<view class='flex flex-direction align-stretch justify-center'>
				<button class='login_fd1_3_c0' @tap.stop="mobileLoginFunc()">登录</button>
			</view>
			
			<view class='flex flex-wrap align-center justify-center login_fd1_4'>
				<text class='login_fd1_4_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/dlzc/sexRegister/sexRegister`">注册账号 </text>
				<view class='flex flex-wrap align-center login_fd1_4_c1'>
				</view>
				<text class='login_fd1_4_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/dlzc/forgetPassword/forgetPassword`">忘记密码</text>
				<!-- <view class='flex flex-wrap align-center login_fd1_4_c1'>
				</view>
				<text class='login_fd1_4_c0' @tap.stop="touristLogin">游客登录</text> -->
			</view>
		</view>
		<web-view v-show="webView" :webview-styles="webviewStyles" :fullscreen="false" src="/hybrid/html/1.html" @message="onPostMessage"></web-view>

		<!---登录flex布局结束-->
		<view class="flex flex-direction align-center benben-position-layout flex login_flex_2">
			<view class='flex flex-wrap align-center login_fd2_0'>
				<benben-flex-switch-new class-name='flex flex login_fd2_0_c0' v-model="is_tick" :disabled='false'>
					<template v-slot:checked>

						<view class='flex flex position-relative align-center' v-if="is_tick===true">
							<image class='login_checkfd2_0_c0_c0_c0' mode="aspectFill" :src='STATIC_URL+"1.png"'></image>
						</view>

					</template>
					<template v-slot:unchecked>

						<view class='flex flex position-relative justify-end align-center' v-if="is_tick===false">
							<image class='login_checkfd2_0_c0_c0_c0' mode="aspectFill" :src='STATIC_URL+"51.png"'>
							</image>
						</view>

					</template>
				</benben-flex-switch-new>
				<text class='login_fd2_0_c1'>已阅读并同意</text>
				<text class='login_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/dlzc/conceal/conceal?type=1`">《用户注册协议》</text>
				<text class='login_fd2_0_c3'>与</text>
				<text class='login_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
					:data-url="`/pages/dlzc/conceal/conceal?type=2`">《隐私政策》</text>
			</view>

		</view>
		<view :style="{height: '300rpx'}"></view>

		<!--区号选择器开始 -->
		<benben-picker ref="benbenWritePickerCodepicker11" :visible.sync="pickerDiy1678760201193" :label.sync='area'
			:value.sync='list' :options='areaList' mode='selector' :mask-show='true' :timeout='true' :picker-height='88'
			default-type='prefix' :default-props='{"label":"country","value":"prefix"}'>
			<template #picker-header>
				<view class='flex flex-wrap align-center justify-between MyInformation_picker5_0'>
					<text @tap="$refs.benbenWritePickerCodepicker11.cancel()">取消</text>
					<text>区号</text>
					<text class='MyInformation_picker5_0_c2'
						@tap="$refs.benbenWritePickerCodepicker11.pickerConfirm()">确认</text>
				</view>
			</template>
		</benben-picker>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'
	import {getImLogin, loginTUICallKit} from '@/commen/login.js'
	export default {
		components: {},


		data() {
			return {
				"mobile": "",
				"password": "",
				"is_tick": false,
				area_code: '',
				area: '',
				"pickerDiy1678760201193": false,
				list: '',
				areaList: [],
				backimg: '',
				timerId: null,
				webviewStyles: {
					width: '1px',
					height: '1px',
					
				},
				webView: false,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			this.is_tick = false
			this.getarea()
			this.getimg()
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 根据ip获取地区
			onPostMessage(e) {
				// console.log(e.detail.data[0].code);
				uni.setStorageSync('ipCode', e.detail.data[0].code);
			},
			// 获取区号
			async getarea() {
				let res = await this.$api.post(global.apiUrls.arealist);
				if (res.data.code != 1) {
					this.$message.info(res.data.msg);
					return
				}
				this.areaList = res.data.data
				// console.log(this.areaList, 'this.areaList')
			},
			//账号密码登录
			async mobileLoginFunc() {
				if (this.timerId) {
					clearTimeout(this.timerId)
				}
				if (!validate(this.list, 'require')) {
					this.$message.info('请选择区号');
					return false;
				}
				if (!validate(this.mobile, 'require')) {
					this.$message.info('请输入手机号');
					return false;
				}
				// if (!validate(this.mobile, 'phone')) {
				// 	this.$message.info('请输入正确的手机号');
				// 	return false;
				// }
				if (!validate(this.password, 'require')) {
					this.$message.info('请输入密码');
					return false;
				}
				if (!validate(this.password, 'password')) {
					this.$message.info('请输入正确的密码');
					return false;
				}
				if (this.is_tick === false) {
					this.$message.info('请阅读并同意用户注册协议和隐私政策');
					return false;
				}
				this.timerId = setTimeout(async () => {
					let res = await this.$api.post(global.apiUrls.mimadenglu, {
						mobile: this.mobile,
						password: this.password,
						area_code: this.list,

					});
					if (res.data.code != 1) {
						this.$message.info(res.data.msg)
						return
					}
					this.$message.info(res.data.msg)
					//清除定时器ID
					this.timerId = null
					this.$store.commit('updateUserInfo', res.data.data.userinfo);
					this.$store.commit('saveToken', res.data.data.userinfo.user_token);
					let options = {
						t_user_id: res.data.data.userinfo.t_user_id,
						user_sig: res.data.data.userinfo.user_sig,
					}
					getImLogin(options);
					loginTUICallKit(options);
					setTimeout(() => {
						uni.reLaunch({
							url: '/pages/tabBar/index/index'
						})
					}, 300)

				}, 500)
			},
			async touristLogin() {
				if (this.is_tick === false) {
					this.$message.info('请阅读并同意用户注册协议和隐私政策');
					return false;
				}
				let res = await this.$api.post(global.apiUrls.a6491005922266, {});
				// console.log(res, 'res')
				this.$message.info(res.data.msg)
				this.$store.commit('updateUserInfo', res.data.data.userinfo);
				this.$store.commit('saveToken', res.data.data.userinfo.user_token);
				setTimeout(() => {
					uni.reLaunch({
						url: '/pages/tabBar/index/index'
					})
				}, 800)
			},
			//获取背景图
			async getimg() {
				let res = await this.$api.post(global.apiUrls.a647dc0f8b7df1);
				if (res.data.code != 1) {
					this.$message.info(res.data.msg)
					return
				}
				this.backimg = res.data.data.app_bg_img
				uni.setStorageSync('backgound', this.backimg)
				// console.log(this.backimg, 'this.backimg')
			},
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background-size: 100% 100% !important;
	}

	.login_fd0_0_c0 {
		background: transparent;
		width: 180rpx;
		height: 180rpx;
		border-radius: 8rpx;
		background-size: 100% auto !important;
	}

	.login_fd0_0 {
		padding: 110rpx 0rpx 80rpx 0rpx;
	}

	.login_flex_1 {
		padding: 0rpx 56rpx 0rpx 56rpx;
	}

	.login_fd1_4_c1 {
		background: rgba(191, 191, 191, 1);
		width: 1rpx;
		height: 24rpx;
		background-size: 100% auto !important;
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.login_fd1_4_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(191, 191, 191, 1);
	}

	.login_fd1_4 {
		line-height: 40rpx;
		margin: 40rpx 0rpx 0rpx 0rpx;
	}

	.login_fd1_3_c0 {
		background: #6A0002;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 500;
		width: 638rpx;
	}

	.login_fd1_2 {
		line-height: 34rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #f5f5f5;
		margin: 32rpx 0rpx 48rpx 0rpx;
	}

	.login_fd1_1_c1_icon2 {
		text-align: center;
		font-size: 44rpx;
	}

	.login_fd1_1_c1_icon1 {
		text-align: center;
		font-size: 44rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	::v-deep .login_fd1_1_c1 {
		font-size: 32rpx;
		color: #f5f5f5;
		font-weight: 400;
		width: 560rpx;
	}

	.login_fd1_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #f5f5f5;
	}

	.login_fd1_0_c0 {
		width: 34rpx;
		height: 34rpx;
		margin: 0rpx 28rpx 0rpx 0rpx;
	}

	.login_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 40rpx 0rpx;
	}

	.MyInformation_picker5_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 0rpx 32rpx 0rpx 32rpx;
		line-height: 88rpx;
		border-radius: 25rpx 25rpx 0rpx 0rpx;
		background-size: 100% auto !important;
	}

	.MyInformation_picker5_0_c2 {
		color: #4781f5;
	}

	.login_flex_2 {
		background: transparent;
		width: 750rpx;
		height: 300rpx;
		overflow: hidden;
		z-index: 0;
		bottom: calc(0rpx + var(--window-bottom));
		background-size: 100% auto !important;
		// top:480px
	}

	.login_fd2_0_c3 {
		line-height: 32rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	.login_fd2_0_c2 {
		line-height: 32rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #347fe5;
	}

	.login_fd2_0_c1 {
		line-height: 32rpx;
		font-size: 22rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	.login_checkfd2_0_c0_c0_c0 {
		width: 36rpx;
		height: 36rpx;
	}

	::v-deep .login_fd2_0_c0 {
		margin: 0rpx 8rpx 0rpx 0rpx;
	}

	.login_fd2_0 {
		margin: auto 0rpx 32rpx 0rpx;
	}
</style>
